stack: Increase reference only if page is non-NULL
authorMohammed Sadiq <sadiq@sadiqpk.org>
Wed, 24 Mar 2021 13:48:02 +0000 (19:18 +0530)
committerMohammed Sadiq <sadiq@sadiqpk.org>
Wed, 24 Mar 2021 14:51:13 +0000 (20:21 +0530)
g_list_nth_data() may return NULL if position is off the end

gtk/gtkstack.c

index 41aa4958b5ec1ad73e563366f28d4fe038c2d795..9b1488b3b20a261f275201bee5c1d4d05b2e2ced 100644 (file)
@@ -538,6 +538,9 @@ gtk_stack_pages_get_item (GListModel *model,
 
   page = g_list_nth_data (priv->children, position);
 
+  if (!page)
+    return NULL;
+
   return g_object_ref (page);
 }